# coding=utf-8
from flask import session,redirect



class sess(object):

    @classmethod
    def set_data(cls,**kwargs):

        for key ,value in kwargs.items():
            session[str(key)] = str(value)

    @classmethod
    def get_data(cls,key):
        return session.get(key)

    @classmethod
    def admin_is_login(cls,fn):
        from functools import wraps
        @wraps(fn)
        def inner(*args,**kwargs):
            _admin_id = sess.get_data('admin_id')
            if not _admin_id:
                return redirect('/admin/login/')
            return fn(*args,**kwargs)
        return inner


